﻿Public Class BlockNineHomeworkSectionThree
    Dim QuestionNumber As Integer
    Dim dtmTest, dtmTest2 As Date
    Dim filename As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    'Declare the Array as 10 rows and 3 columns
    Dim ArrayMax As Integer = 20 'One number past the end of actual info in array
    Dim HWQuestions(ArrayMax, 7) As String
    Dim intResponse As Integer
    Dim intQuestionCount As Integer = 0
    Dim intAnswerCount As Integer = 0
    Dim intReferenceCount As Integer = 0
    Dim intFirstRun As Integer = 1
    Dim strUser As String = "Enter Last Name"
    Dim strAnswer, strAnswer2, strAnswer3, strAnswer4, strAnswer5, _
     strAnswer6, strAnswer7, strAnswer8, strAnswer9, strAnswer10, strAnswer11, _
     strAnswer12, strAnswer13, strAnswer14, strAnswer15, strAnswer16, _
     strAnswer17, strAnswer18, strAnswer19, strAnswer20, strAnswer21, _
     strAnswer22, strAnswer23, strAnswer24, strAnswer25, strAnswer26, _
     strAnswer27, strAnswer28, strAnswer29, strAnswer30, strAnswer31 As String
    Dim intChoiceACount As Integer = 2
    Dim intChoiceBCount As Integer = 3
    Dim intChoiceCCount As Integer = 4
    Dim intChoiceDCount As Integer = 5

    Shared Property MidiParent As MainForm

    Private Sub CloseToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles CloseToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub BlockTwoHomeworkSectionOne_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        txtObj.Text = "Objectives:" + vbCrLf + "- Given proper student instructional materials, identify the operating principles of the pulse train processing section."
        If (System.IO.File.Exists(filename & "\Homework\Block 9\Block 9 Section 3.txt")) Then
            intResponse = MsgBox("This assignment has already been completed.  Are you sure you want to delete the current assignment and reaccomplish it?", 4, "Confirm Assignment Deletion")
            If intResponse = MsgBoxResult.Yes Then
                System.IO.File.Delete(filename & "\Homework\Block 9\Block 9 Section 3.txt")
                System.IO.File.Create(filename & "\Homework\Block 9\Block 9 Section 3.txt").Dispose()
            ElseIf intResponse = MsgBoxResult.No Then
                Me.Close()
            End If
        End If
        If (Not System.IO.File.Exists(filename & "\Homework\Block 9\Block 9 Section 3.txt")) Then
            System.IO.File.Create(filename & "\Homework\Block 9\Block 9 Section 3.txt").Dispose()
        End If
        If (Not System.IO.File.Exists(filename & "\Instructor\Block 9\Block 9 Section 3.txt")) Then
            System.IO.File.Create(filename & "\Instructor\Block 9\Block 9 Section 3.txt").Dispose()
        End If
        chkboxChoiceA.Visible = False
        chkboxChoiceB.Visible = False
        chkboxChoiceC.Visible = False
        chkboxChoiceD.Visible = False
        Matching2.Visible = False
        strUser = InputBox("Please enter last name", strUser)
        If strUser Is "" Then
            Me.Close()
        End If
        '************************************************
        '****** Questions Are Loaded Here****************
        '******* Column 1 is Questions (Preloaded)*******
        '******* Column 2 is Accepts Students Answer*****
        '******* Column 3 is Reference ******************

        HWQuestions(1, 1) = ""
        HWQuestions(1, 2) = ""
        HWQuestions(1, 4) = ""
        HWQuestions(1, 5) = ""
        HWQuestions(1, 6) = ""
        HWQuestions(1, 3) = ""

        HWQuestions(2, 1) = ""
        HWQuestions(2, 2) = ""
        HWQuestions(2, 4) = ""
        HWQuestions(2, 5) = ""
        HWQuestions(2, 6) = ""
        HWQuestions(2, 3) = ""

        HWQuestions(3, 1) = ""
        HWQuestions(3, 2) = ""
        HWQuestions(3, 3) = ""

        HWQuestions(4, 1) = ""
        HWQuestions(4, 2) = ""
        HWQuestions(4, 3) = ""

        HWQuestions(5, 1) = ""
        HWQuestions(5, 2) = ""
        HWQuestions(5, 4) = ""
        HWQuestions(5, 5) = ""
        HWQuestions(5, 6) = ""
        HWQuestions(5, 3) = ""

        HWQuestions(6, 1) = ""
        HWQuestions(6, 2) = ""
        HWQuestions(6, 4) = ""
        HWQuestions(6, 5) = ""
        HWQuestions(6, 6) = ""
        HWQuestions(6, 3) = ""

        HWQuestions(7, 1) = ""
        HWQuestions(7, 2) = ""
        HWQuestions(7, 4) = ""
        HWQuestions(7, 5) = ""
        HWQuestions(7, 6) = ""
        HWQuestions(7, 3) = ""

        HWQuestions(8, 1) = ""
        HWQuestions(8, 2) = ""
        HWQuestions(8, 4) = ""
        HWQuestions(8, 5) = ""
        HWQuestions(8, 6) = ""
        HWQuestions(8, 3) = ""

        HWQuestions(9, 1) = ""
        HWQuestions(9, 2) = ""
        HWQuestions(9, 4) = ""
        HWQuestions(9, 5) = ""
        HWQuestions(9, 6) = ""
        HWQuestions(9, 3) = ""

        HWQuestions(10, 1) = ""
        HWQuestions(10, 2) = ""
        HWQuestions(10, 4) = ""
        HWQuestions(10, 5) = ""
        HWQuestions(10, 6) = ""
        HWQuestions(10, 3) = ""

        HWQuestions(11, 1) = ""
        HWQuestions(11, 2) = ""
        HWQuestions(11, 4) = ""
        HWQuestions(11, 5) = ""
        HWQuestions(11, 6) = ""
        HWQuestions(11, 3) = ""

        HWQuestions(12, 1) = ""
        HWQuestions(12, 2) = ""
        HWQuestions(12, 4) = ""
        HWQuestions(12, 5) = ""
        HWQuestions(12, 6) = ""
        HWQuestions(12, 3) = ""

        HWQuestions(13, 1) = ""
        HWQuestions(13, 2) = ""
        HWQuestions(13, 4) = ""
        HWQuestions(13, 5) = ""
        HWQuestions(13, 6) = ""
        HWQuestions(13, 3) = ""

        HWQuestions(14, 1) = ""
        HWQuestions(14, 2) = ""
        HWQuestions(14, 4) = ""
        HWQuestions(14, 5) = ""
        HWQuestions(14, 6) = ""
        HWQuestions(14, 3) = ""

        HWQuestions(15, 1) = ""
        HWQuestions(15, 2) = ""
        HWQuestions(15, 4) = ""
        HWQuestions(15, 5) = ""
        HWQuestions(15, 6) = ""
        HWQuestions(15, 3) = ""

        HWQuestions(16, 1) = ""
        HWQuestions(16, 2) = ""
        HWQuestions(16, 4) = ""
        HWQuestions(16, 5) = ""
        HWQuestions(16, 6) = ""
        HWQuestions(16, 3) = ""

        HWQuestions(17, 1) = ""
        HWQuestions(17, 2) = ""
        HWQuestions(17, 4) = ""
        HWQuestions(17, 5) = ""
        HWQuestions(17, 6) = ""
        HWQuestions(17, 3) = ""

        HWQuestions(18, 1) = ""
        HWQuestions(18, 2) = ""
        HWQuestions(18, 4) = ""
        HWQuestions(18, 5) = ""
        HWQuestions(18, 6) = ""
        HWQuestions(18, 3) = ""

        HWQuestions(19, 1) = ""
        HWQuestions(19, 2) = ""
        HWQuestions(19, 4) = ""
        HWQuestions(19, 5) = ""
        HWQuestions(19, 6) = ""
        HWQuestions(19, 3) = ""

        HWQuestions(20, 1) = ""

        Next_Question(HWQuestions)
    End Sub

    Private Sub btnNextQuestion_Click(sender As System.Object, e As System.EventArgs) Handles btnNextQuestion.Click
        Next_Question(HWQuestions)
    End Sub
    Private Sub Clear_Display()
        txtQuestion.Clear()
        txtAnswer.Clear()
        txtChoiceA.Clear()
        txtChoiceB.Clear()
        txtChoiceC.Clear()
        txtChoiceD.Clear()
    End Sub

    Public Function Next_Question(HWQuestions As String(,))
        txtAnswer.Focus()
        If intQuestionCount > 0 Then
            WriteToFile()
        End If
        If btnNextQuestion.Text = "Done" Then
            Me.Close()
            OpenResults()
        End If
        intQuestionCount = intQuestionCount + 1
        If intQuestionCount = 19 Then
            btnNextQuestion.Text = "Done"
        End If
        If intQuestionCount = 3 Or intQuestionCount = 4 Then
            txtAnswer.Visible = True
            lblAnswer.Visible = True
            txtChoiceA.Visible = False
            txtChoiceB.Visible = False
            txtChoiceC.Visible = False
            txtChoiceD.Visible = False
            lblChoiceA.Visible = False
            lblChoiceB.Visible = False
            lblChoiceC.Visible = False
            lblChoiceD.Visible = False
            chkboxChoiceA.Visible = False
            chkboxChoiceB.Visible = False
            chkboxChoiceC.Visible = False
            chkboxChoiceD.Visible = False

            txtQuestion.Text = HWQuestions(intQuestionCount, 1)
            intAnswerCount = intAnswerCount + 1
            HWQuestions(intAnswerCount, 2) = txtAnswer.Text
            intReferenceCount = intReferenceCount + 1
            txtReference.Text = HWQuestions(intReferenceCount, 3)
            txtAnswer.Focus()
        End If
        If intQuestionCount = 1 Or intQuestionCount = 2 Or intQuestionCount = 5 _
            Or intQuestionCount = 6 Or intQuestionCount = 7 Or intQuestionCount = 8 _
            Or intQuestionCount = 9 Or intQuestionCount = 10 Or intQuestionCount = 12 _
            Or intQuestionCount = 13 Or intQuestionCount = 14 Or intQuestionCount = 15 _
            Or intQuestionCount = 16 Or intQuestionCount = 17 Or intQuestionCount = 18 _
            Or intQuestionCount = 19 Then
            txtAnswer.Visible = False
            lblAnswer.Visible = False
            txtChoiceA.Visible = True
            txtChoiceB.Visible = True
            txtChoiceC.Visible = True
            txtChoiceD.Visible = True
            lblChoiceA.Visible = True
            lblChoiceB.Visible = True
            lblChoiceC.Visible = True
            lblChoiceD.Visible = True
            chkboxChoiceA.Visible = True
            chkboxChoiceB.Visible = True
            chkboxChoiceC.Visible = True
            chkboxChoiceD.Visible = True
            Matching2.Visible = False
            txtObj.Visible = True

            txtQuestion.Text = HWQuestions(intQuestionCount, 1)
            txtChoiceA.Text = HWQuestions(intQuestionCount, 2)
            txtChoiceB.Text = HWQuestions(intQuestionCount, 4)
            txtChoiceC.Text = HWQuestions(intQuestionCount, 5)
            txtChoiceD.Text = HWQuestions(intQuestionCount, 6)
        End If
        If intQuestionCount = 11 Then
            txtAnswer.Visible = False
            lblAnswer.Visible = False
            txtChoiceA.Visible = False
            txtChoiceB.Visible = False
            txtChoiceC.Visible = False
            txtChoiceD.Visible = False
            lblChoiceA.Visible = False
            lblChoiceB.Visible = False
            lblChoiceC.Visible = False
            lblChoiceD.Visible = False
            chkboxChoiceA.Visible = False
            chkboxChoiceB.Visible = False
            chkboxChoiceC.Visible = False
            chkboxChoiceD.Visible = False
            txtObj.Visible = False
            Matching2.Visible = True
            txtQuestion.Text = HWQuestions(intQuestionCount, 1)
        End If
        Return intQuestionCount & intAnswerCount
    End Function
    Private Sub WriteToFile()
        Dim Integrity As String = (filename & "\Instructor\Block 9\Block 9 Section 3.txt")
        Dim Results As String = (filename & "\Homework\Block 9\Block 9 Section 3.txt")

        '***********Output to hidden file for Instructor Check***********
        If System.IO.File.Exists(Integrity) = True Then
            Dim hiddenWriter As New System.IO.StreamWriter(Integrity, True)
            If intQuestionCount = 1 Then
                hiddenWriter.WriteLine()
                hiddenWriter.WriteLine("Student: " & strUser)
                hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If

            If intQuestionCount = 1 Or intQuestionCount = 2 Or intQuestionCount = 5 _
                    Or intQuestionCount = 6 Or intQuestionCount = 7 Or intQuestionCount = 8 _
                    Or intQuestionCount = 9 Or intQuestionCount = 10 Or intQuestionCount > 11 Then
                hiddenWriter.WriteLine("Question:" & txtQuestion.Text)
                If chkboxChoiceA.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  A: " & txtChoiceA.Text)
                ElseIf chkboxChoiceB.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  B: " & txtChoiceB.Text)
                ElseIf chkboxChoiceC.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  C: " & txtChoiceC.Text)
                ElseIf chkboxChoiceD.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  D: " & txtChoiceD.Text)
                End If
            End If
            If intQuestionCount = 3 Or intQuestionCount = 4 Then
                hiddenWriter.WriteLine("Question:" & txtQuestion.Text)
                hiddenWriter.WriteLine("Answer:" & txtAnswer.Text)
            End If
            If intQuestionCount = 11 Then
                hiddenWriter.WriteLine(lblColumnB1.Text & ": " & txtM2Q1.Text)
                hiddenWriter.WriteLine(lblColumnB2.Text & ": " & txtM2Q2.Text)
                hiddenWriter.WriteLine(lblColumnB3.Text & ": " & txtM2Q3.Text)
                hiddenWriter.WriteLine(lblColumnB4.Text & ": " & txtM2Q4.Text)
                hiddenWriter.WriteLine(lblColumnB5.Text & " : " & txtM2Q5.Text)
                hiddenWriter.WriteLine(lblColumnB6.Text & " : " & txtM2Q6.Text)
                hiddenWriter.WriteLine(lblColumnB7.Text & " : " & txtM2Q7.Text)
                hiddenWriter.WriteLine(lblColumnB8.Text & " : " & txtM2Q8.Text)
                hiddenWriter.WriteLine(lblColumnB9.Text & " : " & txtM2Q9.Text)
                hiddenWriter.WriteLine(lblColumnB10.Text & " : " & txtM2Q10.Text)
                hiddenWriter.WriteLine(lblColumnB11.Text & " : " & txtM2Q11.Text)
                hiddenWriter.WriteLine(lblColumnB12.Text & " : " & txtM2Q12.Text)
                hiddenWriter.WriteLine(lblColumnB13.Text & " : " & txtM2Q13.Text)
                hiddenWriter.WriteLine(lblColumnB14.Text & " : " & txtM2Q14.Text)
                'hiddenWriter.WriteLine(lblColumnB15.Text & " : " & txtMatch15.Text)
                'hiddenWriter.WriteLine(lblColumnB16.Text & " : " & txtMatch16.Text)
                'hiddenWriter.WriteLine(lblCOlumnB17.Text & " : " & txtMatch17.Text)
                'hiddenWriter.WriteLine(lblColumnB18.Text & " : " & txtMatch18.Text)
            End If

            hiddenWriter.WriteLine("Reference: " & txtReference.Text)
            hiddenWriter.WriteLine()
            If intQuestionCount = 19 Then
                hiddenWriter.WriteLine("Block 2 Section 1 Homework Complete")
                hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.Close()

            'MsgBox("Text written to file")
        Else
            MsgBox("File Does Not Exist Integrity")
        End If

        '******Output to file for Student to review***********
        If System.IO.File.Exists(Results) = True Then
            Dim hiddenWriter As New System.IO.StreamWriter(Results, True)
            If intQuestionCount = 1 Then
                hiddenWriter.WriteLine()
                hiddenWriter.WriteLine("Student: " & strUser)
                'hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                'hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            If intQuestionCount = 1 Or intQuestionCount = 2 Or intQuestionCount = 5 _
                    Or intQuestionCount = 6 Or intQuestionCount = 7 Or intQuestionCount = 8 _
                    Or intQuestionCount = 9 Or intQuestionCount = 10 Or intQuestionCount > 11 Then
                hiddenWriter.WriteLine("Question:" & txtQuestion.Text)
                If chkboxChoiceA.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  A: " & txtChoiceA.Text)
                ElseIf chkboxChoiceB.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  B: " & txtChoiceB.Text)
                ElseIf chkboxChoiceC.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  C: " & txtChoiceC.Text)
                ElseIf chkboxChoiceD.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  D: " & txtChoiceD.Text)
                End If
            End If
            If intQuestionCount = 3 Or intQuestionCount = 4 Then
                hiddenWriter.WriteLine("Question:" & txtQuestion.Text)
                hiddenWriter.WriteLine("Answer:" & txtAnswer.Text)
            End If
            If intQuestionCount = 11 Then
                hiddenWriter.WriteLine("Question: 11")
                hiddenWriter.WriteLine(lblColumnB1.Text & ": " & txtM2Q1.Text + vbTab + vbTab & lblColumnA1.Text)
                hiddenWriter.WriteLine(lblColumnB2.Text & ": " & txtM2Q2.Text + vbTab + vbTab + vbTab + vbTab + vbTab & lblColumnA2.Text)
                hiddenWriter.WriteLine(lblColumnB3.Text & ": " & txtM2Q3.Text + vbTab + vbTab + vbTab & lblColumnA3.Text)
                hiddenWriter.WriteLine(lblColumnB4.Text & ": " & txtM2Q4.Text + vbTab & lblColumnA4.Text)
                hiddenWriter.WriteLine(lblColumnB5.Text & " : " & txtM2Q5.Text + vbTab + vbTab & lblColumnA5.Text)
                hiddenWriter.WriteLine(lblColumnB6.Text & " : " & txtM2Q6.Text + vbTab + vbTab + vbTab & lblColumnA6.Text)
                hiddenWriter.WriteLine(lblColumnB7.Text & " : " & txtM2Q7.Text & lblColumnA7.Text)
                hiddenWriter.WriteLine(lblColumnB8.Text & " : " & txtM2Q8.Text + vbTab + vbTab & lblColumnA8.Text)
                hiddenWriter.WriteLine(lblColumnB9.Text & " : " & txtM2Q9.Text + vbTab + vbTab & lblColumnA9.Text)
                hiddenWriter.WriteLine(lblColumnB10.Text & " : " & txtM2Q10.Text + vbTab + vbTab + vbTab + vbTab & lblColumnA10.Text)
                hiddenWriter.WriteLine(lblColumnB11.Text & " : " & txtM2Q11.Text + vbTab + vbTab + vbTab + vbTab & lblColumnA11.Text)
                hiddenWriter.WriteLine(lblColumnB12.Text & " : " & txtM2Q12.Text + vbTab + vbTab & lblColumnA12.Text)
                hiddenWriter.WriteLine(lblColumnB13.Text & " : " & txtM2Q13.Text + vbTab + vbTab & lblColumnA13.Text)
                hiddenWriter.WriteLine(lblColumnB14.Text & " : " & txtM2Q14.Text + vbTab + vbTab & lblColumnA14.Text)
                hiddenWriter.WriteLine("" + vbTab + vbTab + vbTab + vbTab + vbTab & lblColumnA15.Text)
                hiddenWriter.WriteLine("" + vbTab + vbTab + vbTab + vbTab + vbTab & lblColumnA16.Text)
                hiddenWriter.WriteLine("" + vbTab + vbTab + vbTab + vbTab + vbTab & lblColumnA17.Text)
                hiddenWriter.WriteLine("" + vbTab + vbTab + vbTab + vbTab + vbTab & lblColumnA18.Text)
            End If
            'hiddenWriter.WriteLine("Reference: " & txtReference.Text)
            hiddenWriter.WriteLine()
            If intQuestionCount = 19 Then
                hiddenWriter.WriteLine("Block 9 Section 1 Homework Complete")
                'hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                'hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.Close()

            'MsgBox("Text written to file")
        Else
            MsgBox("File Does Not Exist Results")
        End If

        If intQuestionCount > 0 Then
            txtAnswer.Clear()
            chkboxChoiceA.CheckState = CheckState.Unchecked
            chkboxChoiceB.CheckState = CheckState.Unchecked
            chkboxChoiceC.CheckState = CheckState.Unchecked
            chkboxChoiceD.CheckState = CheckState.Unchecked
        End If

    End Sub

    Private Sub OpenResults()
        Dim p As Process = Process.Start(filename & "\Homework\Block 9\Block 9 Section 3.txt")
    End Sub
End Class
